home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / coreaids.zip / TEXT_RD.ASM < prev    next >
Assembly Source File  |  1987-06-25  |  2KB  |  97 lines

  1. ;    DESC:    Reads text from the screen                           V1.00
  2. ;    IN:    *{PAGE} page number of screen (0-3)
  3. ;        *{ROWCOL} row(0-24), col(0-79) (i.e. 0345) at which to
  4. ;         begin reading from screen
  5. ;        *{NUM_CHARS} # of chars to read
  6. ;    OUT:    *{SEG_VAL} segment and
  7. ;        *{OFFSET} offset of string read
  8. ;    SAMPLE:    Callm    TEXT_RD,<PAGE,ROWCOL,NUM_CHARS>,<SEG_VAL,OFFSET>
  9. ;    ##################################################################
  10.  
  11. TEXT_RDD Segment Para Public 'DATA'
  12. STRNG        DB    80 DUP(0)
  13. PAGEL        DW    0
  14. LINE        DB    160
  15. TEXT_RDD Ends
  16.  
  17.     Extrn    PUSHALL:Near
  18.     Extrn    POPALL:Near
  19.     Extrn    SCRN_TYP:Near
  20.  
  21. TEXT_RDC    Segment
  22.     Assume    CS:TEXT_RDC,DS:TEXT_RDD
  23.     Public    TEXT_RD
  24.  
  25.                         ;notice.
  26.     DB    'TEXT_RD  - V1.00, Copyright 1987, CoreTechs   ',0DH,0AH
  27.  
  28. TEXT_RD    Proc    Near                ;read text from the screen.
  29.  
  30.     Call    PUSHALL                ;save registers.
  31.  
  32.     Mov    AX,TEXT_RDD            ;setup workarea.
  33.     Mov    DS,AX    
  34.  
  35.     Call    SCRN_TYP            ;determine video memory
  36.     Pop    BX                ;location.
  37.  
  38. COLOR:    Mov    AX,4096                ;load page length.
  39.  
  40.     Pop    SI                ;recover number of chars.
  41.     Pop    DI                ;recover row, column offset.
  42.     Pop    CX                ;recover page number.
  43.  
  44.     Push    SI                ;replace number of chars.
  45.     Push    DI                ;replace row,column offset.
  46.  
  47.     Mov    PAGEL,CX            ;find page offset.
  48.     Mul    PAGEL
  49.  
  50.     Mov    CL,4                ;divide by 16 to get
  51.     Shr    AX,CL                ;segment value.
  52.  
  53.      Add    BX,AX                ;load absolute video segment
  54.     Mov    ES,BX                ;in ES.
  55.     
  56.     Pop    AX                ;determine offset of
  57.     Mov    BX,AX                ;row, col on screen.
  58.  
  59.     Xchg    AH,AL                ;change rows to byte offset.
  60.     Mov    AH,0
  61.     Mul    LINE
  62.  
  63.     Mov    BH,0                ;modify column information
  64.     Shl    BX,1                ;to reflect 160 bytes per
  65.     Add    AX,BX                ;line including attributes.
  66.  
  67.     Mov    SI,AX                ;total offset to start read.
  68.  
  69.     Pop    CX                ;recover # of chars to read.
  70.  
  71.     Push    DS                ;prepare to transfer video
  72.     Push    ES                ;memory to internal buffer.
  73.     Pop    DS
  74.     Pop    ES
  75.     Mov    DI,OFFSET STRNG
  76.     Push    DI
  77.     Push    ES
  78.  
  79. GETSTR:    Cld                    ;begin transfer.
  80.     Movs    ES:BYTE PTR[DI],DS:[SI]    
  81.  
  82.     Inc    SI                ;skip attributes.
  83.  
  84.     Dec    CX                ;count down transfer.
  85.  
  86.     Cmp    CX,0                ;are we done?
  87.     Jz    OUTING
  88.  
  89.     Jmp    GETSTR                ;if not done, continue.
  90.  
  91. OUTING:    Call    POPALL                ;restore and return.
  92.     Ret
  93.  
  94. TEXT_RD    Endp
  95. TEXT_RDC    Ends
  96.     End
  97.